home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / rcs55.zip / RCSKEYS.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  3KB  |  98 lines

  1. /*
  2.  *                     RCS keyword table and match operation
  3.  */
  4.  
  5. /* Copyright (C) 1982, 1988, 1989 Walter Tichy
  6.    Copyright 1990 by Paul Eggert
  7.    Distributed under license by the Free Software Foundation, Inc.
  8.  
  9. This file is part of RCS.
  10.  
  11. RCS is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 1, or (at your option)
  14. any later version.
  15.  
  16. RCS is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with RCS; see the file COPYING.  If not, write to
  23. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  24.  
  25. Report problems and direct all questions to:
  26.  
  27.     rcs-bugs@cs.purdue.edu
  28.  
  29. */
  30.  
  31.  
  32.  
  33. /* $Log: rcskeys.c%v $
  34.  * Revision 1.2  1991/08/23  13:35:35  SGP
  35.  * Ported to MSDOS using Borland C++
  36.  *
  37.  * Revision 5.0  1990/08/22  08:12:54  eggert
  38.  * Add -k.  Ansify and Posixate.
  39.  *
  40.  * Revision 4.3  89/05/01  15:13:02  narten
  41.  * changed copyright header to reflect current distribution rules
  42.  * 
  43.  * Revision 4.2  87/10/18  10:36:33  narten
  44.  * Updating version numbers. Changes relative to 1.1 actuallyt
  45.  * relative to 4.1
  46.  * 
  47.  * Revision 1.2  87/09/24  14:00:10  narten
  48.  * Sources now pass through lint (if you ignore printf/sprintf/fprintf 
  49.  * warnings)
  50.  * 
  51.  * Revision 4.1  83/05/04  10:06:53  wft
  52.  * Initial revision.
  53.  * 
  54.  */
  55.  
  56.  
  57. #include "rcsbase.h"
  58.  
  59. libId(keysId, "$Id: rcskeys.c%v 1.2 1991/08/23 13:35:35 SGP Exp $")
  60.  
  61.  
  62. const char *const Keyword[] = {
  63.     /* This must be in the same order as rcsbase.h's enum markers type. */
  64.     nil,
  65.     AUTHOR, DATE, HEADER, IDH,
  66.     LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE,
  67. };
  68.  
  69.  
  70.  
  71.     enum markers
  72. trymatch(const char *string)
  73. /* function: Checks whether string starts with a keyword followed
  74.  * by a KDELIM or a VDELIM.
  75.  * If successful, returns the appropriate marker, otherwise Nomatch.
  76.  */
  77. {
  78.         register int j;
  79.     register const char *p, *s;
  80.     for (j = sizeof(Keyword)/sizeof(*Keyword);  (--j);  ) {
  81.         /* try next keyword */
  82.         p = Keyword[j];
  83.         s = string;
  84.         while (*p++ == *s++) {
  85.             if (!*p)
  86.                 switch (*s) {
  87.                 case KDELIM:
  88.                 case VDELIM:
  89.                     return (enum markers)j;
  90.                 default:
  91.                     return Nomatch;
  92.                 }
  93.         }
  94.         }
  95.         return(Nomatch);
  96. }
  97.  
  98.